package com.yic.module.base.dal.mysql.brand;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.base.dal.dataobject.brand.BrandDO;
import com.yic.module.base.dal.dataobject.center.CenterDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.base.controller.admin.brand.vo.*;

/**
 * 品牌信息 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface BrandMapper extends BaseMapperX<BrandDO> {

    default PageResult<BrandDO> selectPage(BrandPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BrandDO>()
                .likeIfPresent(BrandDO::getName, reqVO.getName())
                .likeIfPresent(BrandDO::getCode, reqVO.getCode())
                .eqIfPresent(BrandDO::getStatus, reqVO.getStatus())
                .orderByDesc(BrandDO::getId));
    }

    default List<BrandDO> selectList(BrandExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BrandDO>()
                .likeIfPresent(BrandDO::getName, reqVO.getName())
                .likeIfPresent(BrandDO::getCode, reqVO.getCode())
                .eqIfPresent(BrandDO::getStatus, reqVO.getStatus())
                .orderByDesc(BrandDO::getId));
    }

    default BrandDO selectByName(String name) {
        return selectOne(new LambdaQueryWrapperX<BrandDO>()
                .eq(BrandDO::getName, name));
    }

    default BrandDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<BrandDO>()
                .eq(BrandDO::getCode, code));
    }

    default List<BrandDO> selectList(Collection<Long> ids, Collection<Integer> statuses) {
        return selectList(new LambdaQueryWrapperX<BrandDO>()
                .inIfPresent(BrandDO::getId, ids)
                .inIfPresent(BrandDO::getStatus, statuses));
    }
}
